const express = require('express');
const router = express.Router();
let db = require('../../db/postgre')
const response = require('../../response')
const request = require('../../request')
const md5 = require('md5')
const Base64 = require('js-base64').Base64
const unit = require('../../unit')
db = new db()

router.get('/', function(req, res, next) {
  db.getClient().then(client => {
    db.createSqlText({func: `query`, table: `cun_mst_building`, params: ['*']}).run(client).then((result) => {
      if (result.length > 0) {
        res.json(result)
      } else {
      }
    }, (err) => {
      response.error(res, `出现错误`)
    })
  })
  /* db.connect().then(client => {
    client.query('SELECT * from cun_mst_building').then(response => {
      client.release()
      // console.log('hello from', res.rows[0].name)
      res.json(response)
    })
    .catch(e => {
      client.release()
      console.error('query error', e.message, e.stack)
    })
  }) */
})
module.exports = router;